home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / gamesmaster / source / asm / screendemos / widescroll.s < prev    next >
Encoding:
Text File  |  1996-09-11  |  3.7 KB  |  141 lines

  1. ;Wide Scroll
  2. ;-----------
  3. ;This opens an extra wide picture of 640x256 pixels and scrolls it left
  4. ;and right.  Extremely large pictures are *totally* inadequate for games
  5. ;such as platformers and shoot'em-ups, because the picture size takes
  6. ;up  huge  amounts  of  memory.   However  for games like Skidmarks,
  7. ;Lemmings, Monkey Island, etc, such large screens can be a necessity.
  8.  
  9.     opt    o+
  10.  
  11.     INCLUDE    "exec/exec_lib.i"
  12.     INCLUDE    "games/games_lib.i"
  13.     INCLUDE    "games/games.i"
  14.  
  15. CALL    MACRO
  16.     jsr    _LVO\1(a6)
  17.     ENDM
  18.  
  19.     SECTION    "WideScroll",CODE
  20.  
  21. ;===========================================================================;
  22. ;                             INITIALISE DEMO
  23. ;===========================================================================;
  24.  
  25. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  26.     move.l    ($4).w,a6
  27.     lea    GMS_Name(pc),a1
  28.     moveq    #$00,d0
  29.     CALL    OpenLibrary
  30.     move.l    d0,GMS_Base
  31.     beq.s    Quit
  32.  
  33.     move.l    GMS_Base(pc),a6          ;Tell GMS that we want to add a
  34.     CALL    SetUserPri
  35.  
  36.     lea    ScreenStruct(pc),a0      ;screen for use.
  37.     CALL    Add_Screen
  38.     tst.l    d0
  39.     bne.s    Error
  40.  
  41.     lea    PicFile(pc),a0           ;a0 = Picture file.
  42.     lea    Picture(pc),a1           ;a1 = Picture struct.
  43.     move.l    ScreenStruct+SS_MemPtr1(pc),PIC_Data(a1)
  44.     CALL    LoadPic
  45.     tst.w    d0
  46.     bne.s    ReturnToDOS
  47.  
  48.     lea    ScreenStruct(pc),a0      ;Now show the screen/pic.
  49.     CALL    Show_Screen
  50.  
  51. ;===========================================================================;
  52. ;                                MAIN LOOP
  53. ;===========================================================================;
  54.  
  55.     moveq    #0,d2
  56.  
  57. Loop:    CALL    Wait_OSVBL
  58.     tst.w    d2
  59.     bgt.s    .Right
  60.  
  61. .Left    tst.w    SS_PicXOffset(a0)
  62.     ble.s    .Right
  63.     moveq    #-2,d2
  64.     bra.s    .scroll
  65.  
  66. .Right    cmp.w    #320,SS_PicXOffset(a0)
  67.     bge.s    .Left
  68.     moveq    #2,d2
  69.  
  70. .scroll    add.w    d2,SS_PicXOffset(a0)
  71.     CALL    Move_Picture
  72.  
  73. .done    moveq    #JPORT1,d0               ;Port 1 (Mouse)
  74.     moveq    #JT_ZBXY,d1
  75.     CALL    Read_JoyPort
  76.     btst    #MB_LMB,d0
  77.     beq.s    Loop
  78.  
  79. ;===========================================================================;
  80. ;                              RETURN TO DOS
  81. ;===========================================================================;
  82.  
  83. ReturnToDOS:
  84.     move.l    GMS_Base(pc),a6
  85.     lea    ScreenStruct(pc),a0
  86.     CALL    Delete_Screen            ;Give back screen memory etc.
  87. Error:    move.l    GMS_Base(pc),a1
  88.     move.l    ($4).w,a6
  89.     CALL    CloseLibrary
  90. Quit:    MOVEM.L    (SP)+,A0-A6/D1-D7
  91.     moveq    #$00,d0
  92.     rts
  93.  
  94. ;===========================================================================;
  95. ;                                  DATA
  96. ;===========================================================================;
  97.  
  98. Direction:
  99.     dc.w    0
  100.  
  101. GMS_Name:
  102.     dc.b    "games.library",0
  103.     even
  104. GMS_Base:
  105.     dc.l    0
  106.  
  107. AMT_PLANES =    4
  108.  
  109. ScreenStruct:
  110.     dc.l    "GSV1",0
  111.     dc.l    0,0,0             ;Screen_Mem1/2/3
  112.     dc.l    0                 ;Screen link.
  113.     dc.l    Palette           ;Address of palette
  114.     dc.l    0                 ;Address of rasterlist.
  115.     dc.l    16                ;Amt of colours in palette.
  116.     dc.w    320,256,640,256   ;Screen & Pic Height/Width. 
  117.     dc.w    AMT_PLANES        ;Amt_Planes
  118.     dc.w    0,0               ;Top Of Screen, X/Y
  119.     dc.w    0,0               ;X/Y offsets.
  120.     dc.l    HSCROLL           ;Special attributes.
  121.     dc.w    LORES             ;Screen mode.
  122.     dc.b    INTERLEAVED       ;Screen type
  123.     dc.b    0                 ;Reserved.
  124.     even
  125.  
  126. Palette    dc.w    $0000,$0400,$0501,$0501,$0601,$0701,$0701,$0801
  127.     dc.w    $0901,$0A01,$0B02,$0432,$0CC0,$0F00,$0211,$0880
  128.  
  129. Picture    dc.l    "PCV1",0           ;Version header.
  130.     dc.l    0                  ;Source data.
  131.     dc.w    640,256            ;Width, Height.
  132.     dc.w    AMT_PLANES         ;Amount of Planes.
  133.     dc.l    16                 ;Amount of colours.
  134.     dc.l    Palette            ;Source palette (remap).
  135.     dc.w    LORES              ;Screen mode.
  136.     dc.w    INTERLEAVED        ;Destination
  137.     dc.l    0                  ;Parameters.
  138.  
  139. PicFile    dc.b    "GAMESLIB:data/IFF.Pic640x256",0
  140.     even
  141.